<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>新增商品</h2>
    </div>
    <form action="{:U(add)}" method="post" class="form-horizontal" enctype="multipart/form-data">
        <div class="form-item">
            <label class="item-label">商品名<span class="check-tips">（name）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">商品描述<span class="check-tips">（des）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="des" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">商品分类<span class="check-tips">（pid）</span></label>
            <div class="controls">
                <select id='con' class="cate" name="fid">
                  <option value="">请选择</option>
                  <volist name='res' id='s' empty='暂时没有数据'>
                    <option value="{$s.id}">{$s.title}</option>
                  </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">商品图片<span class="check-tips">（pic）</span></label>
            <div class="controls">
                <input type="file" class="input-large" name="pic" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">状态<span class="check-tips">（status）</span><span class="check-tips"></span></label>
            <div class="controls">
            	<label class='radio'>
                显示：<input type="radio" name="status" value="1" checked></label>
                <label class='radio'>隐藏：<input type="radio" name="status" value="0"></label>
            </div>
        </div>
        <div class="form-item">
            <button class="btn submit-btn " id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript">


             $("body").on("change","#con",function(){
               // alert(1111);
                 var iq=$(this);
                 var id=iq.val();
                 //console.log(id);
                 $.ajax({
                   type:"POST",
                   url:"{:U('Goods/xiala')}",
                   data:{id:id},
                   success:function(data){
                     if(data.status==1){
                       iq.nextAll().remove();
                       $("#con").after(data.data);
                     }else{
                       iq.nextAll().remove();
                     }
                   }
                 });
                //  $.ajax({
                //      type:"POST",
                //      url:"{:U('Goods/xiala')}",
                //      data:{id:id},
                //      success:function(data){
                //      console.log(data);
                //      if(data.status==1){
                //          iq.nextAll().remove();
                //         $("#con").append(data.data);
                //      }else{
                //           iq.nextAll().remove();
                //      }
                //    }
                //   });

             });



  highlight_subnav('{:U('Goods/add')}');

     </script>
</block>
